<%- include('header.html')  -%>

<div class="container mt-5 min-vh-100">
    <h2 class="mb-4">当前方向：<%=category.name%></h2>
    <div class="row row-cols-4">
        <% if (user&&user.mjr) { %> 
            <% articles.forEach(article => { %>
                <% if (article.major==user.mjr) { %>
                    <div class="col my-3">
                        <div class="card h-100">
                            <div class="card-body">
                                <h5 class="card-title"><%= article.id %>) <%= article.title %></h5>
                                <p class="card-text"><small class="text-muted"><%= article.time.toLocaleString() %></small></p>
                                <p class="card-text"><%= article.content.replace(/<[^>]+>/g,'').substring(0,80) %>...</p>
                                <a href="/article/<%=article.id%>" class="stretched-link"></a>
                            </div>
                        </div>
                    </div>
                    <% } %>
                    <% }) %>
        <% } else { %>
            <% articles.forEach(article => { %>
                    <div class="col my-3">
                        <div class="card h-100">
                            <div class="card-body">
                                <h5 class="card-title"><%= article.id %>) <%= article.title %></h5>
                                <p class="card-text"><small class="text-muted"><%= article.time.toLocaleString() %></small></p>
                                <p class="card-text"><%= article.content.replace(/<[^>]+>/g,'').substring(0,80) %>...</p>
                                <a href="/article/<%=article.id%>" class="stretched-link"></a>
                            </div>
                        </div>
                    </div>
                    <% }) %>
        <% } %>

    </div>
</div>


<%- include('footer.html')  -%>